home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / recent2 / yamtools.lha / yamtools1.4 / YTDelete.rexx < prev    next >
OS/2 REXX Batch file  |  1997-03-01  |  9KB  |  269 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*                             YTDelete                                       */
  4. /*                 Copyright ©1997 by Dick Whiting                            */
  5. /*                                                                            */
  6. /*----------------------------------------------------------------------------*/
  7. /* This script requires YAMTOOLS for it to work. If you don't have YAMTOOLS   */
  8. /* you can get it on Aminet in directory comm/mail. This script allows you    */
  9. /* to Delete all selected mail. This is only really useful from               */
  10. /* the mail list of a SEARCH. Otherwise, use YAM's normal capabilities.       */
  11. /*                                                                            */
  12. /*----------------------------------------------------------------------------*/
  13. /*                                                                            */
  14. /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee        */
  15. /* that it will do anything productive for anyone else, etc. etc. ;-)         */
  16. /*                                                                            */
  17. /*HOWEVER, if you DO find a use for it: I homeschool my kids and they         */
  18. /*would love a postcard from where EVER you live.                             */
  19. /*                                                                            */
  20. /*Instant GEOGRAPHY lesson;)                                                  */
  21. /*                                                                            */
  22. /*                                                                            */
  23. /*POSTCARDS:    Dick Whiting                                                  */
  24. /*              28590 S. Beavercreek Rd.                                      */
  25. /*              Mulino, Oregon 97042                                          */
  26. /*              USA                                                           */
  27. /*                                                                            */
  28. /*----------------------------------------------------------------------------*/
  29. /*                                                                            */
  30. /*               Address Bug Reports or Comments to:                          */
  31. /*                Dick Whiting <dwhiting@europa.com>                          */
  32. /*                         28 February 1997                                   */
  33. /*                                                                            */
  34. /******************************************************************************/
  35. /*
  36. $VER: 1.0 Copyright ©1997 by Dick Whiting
  37. $AUTHOR: Dick Whiting
  38. $DESCRIPTION: Deleter for use with YAMTOOLS
  39. */
  40.  
  41. options results
  42. options failat 9999         /* keep maildelete return from showing */
  43.  
  44. MUIA_List_Entries =         0x80421654 
  45. MUIA_VertWeight =           0x804298d0 
  46. MUIA_Window_DepthGadget  =  0x80421923
  47. MUIA_Window_DragBar  =      0x8042045d
  48. MUIA_Window_PublicScreen =  0x804278e4
  49. MUIA_Window_SizeGadget  =   0x8042e33d
  50.  
  51. TRUE=1
  52. FALSE=0
  53.  
  54. help.SQUIT=''
  55. node.SQUIT=''
  56. help.STEXT=''
  57. node.STEXT=''
  58.  
  59. missing='.'
  60.  
  61. Address YAMTOOLS
  62.  
  63. Call CheckYam
  64.  
  65. Call CheckMailList
  66. Call ProcessDeletes
  67.  
  68. exit
  69.  
  70. /**************************************************************************/
  71. /*                Check that there is some mail to process                */
  72. /**************************************************************************/
  73. CheckMailList:
  74.  
  75.    list ID MLST ATTRS MUIA_List_Entries
  76.    mcnt=result
  77.    if mcnt=0 then do
  78.       errmsg='You need to CHOOSE mail to Delete'
  79.       Call ErrorMsg
  80.    end
  81.  
  82. Return
  83.  
  84.  
  85. /**************************************************************************/
  86. /*                           Process Deletes                              */
  87. /**************************************************************************/
  88. ProcessDeletes:
  89.  
  90.  
  91.    request ID VERD GADGETS '"OK|CANCEL"' '"Delete selected entries?"'
  92.    if result=0 then exit
  93.  
  94.    infotitle='"YAM Tools Info"'
  95.    infotext='\033nDeleting Mail...'
  96.    infobuttons='"Continue,Interrupt,Abort"'
  97.    showbusy=TRUE
  98.  
  99.    Call InfoWindow
  100.    
  101.    list ID MLST ATTRS MUIA_List_Entries
  102.    mcnt=result
  103.  
  104.    Deletelist.=missing
  105.    Deletelist.0=0
  106.    Updlist.=missing
  107.    Updlist.0=0
  108.    acnt=0
  109.  
  110.    do i=0 to mcnt-1
  111.       list ID MLST
  112.       mline=result
  113.       if mline='' then break
  114.       parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
  115.       acnt=acnt+1
  116.       anum=right(anum,6,'0')
  117.       mnum=right(mnum,6,'0')
  118.       Deletelist.0=acnt
  119.       Deletelist.acnt=anum mnum file subj
  120.       radio ID SQUIT 
  121.       if result~="Continue" then leave
  122.    end
  123.    Updlist.0=Deletelist.0
  124.  
  125.    if acnt=0 then do
  126.       errmsg='You need to SELECT mail to Delete'
  127.       Call ErrorMsg     
  128.    end
  129.  
  130.    if show('L','rexxtricks.library') then do    /* use tricks library     */
  131.       call QSORT(Deletelist)                 /* sort by name, line number */
  132.    end
  133.    else do                                   /* use QuickSort format      */
  134.       call QSORT(1, Deletelist.0, Deletelist) /* sort by name, number     */
  135.    end 
  136.  
  137.    do i=Deletelist.0 to 1 by -1              /* process in reverse order  */
  138.       anum=word(Deletelist.i,1)
  139.       anum=strip(anum,'L','0')
  140.       if anum='' then anum=0
  141.       mnum=word(Deletelist.i,2)
  142.       mnum=strip(mnum,'L','0')
  143.       if mnum='' then mnum=0
  144.       file=word(Deletelist.i,3)
  145.       subj=subword(Deletelist.i,4)
  146.       Updlist.i=anum
  147.       Updlist.i.1=mnum
  148.       Updlist.i.1.1=file
  149.       Updlist.i.1.1.1=subj
  150.       Address YAM 'setfolder 'anum           /* goto folder               */
  151.       Address YAM 'setmail 'mnum             /* set to mail               */
  152.       Address YAM "getmailinfo file"         /* verify filename           */
  153.       xfile=result
  154.       xlen=length(file)
  155.       xfile=right(xfile,xlen)
  156.       Address YAM "getmailinfo subject"      /* verify subject            */
  157.       xsubj=result      
  158.       xsubj=translate(xsubj,' ',',')
  159.       if file~=xfile | xsubj~=subj then do
  160.          Updlist.i.1.1.1.1='\033berror'
  161.       end 
  162.       else do
  163.          Updlist.i.1.1.1.1='\033bDeleted'
  164.          Address YAM "maildelete" 
  165.       end
  166.    end
  167.    
  168.    do i=1 to Updlist.0
  169.       do j=0 to mcnt-1
  170.          list ID MLST POS j
  171.          mline=result
  172.          if mline='' then break
  173.          parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
  174.          if Updlist.i=anum & Updlist.i.1=mnum then do
  175.             arch=Updlist.i.1.1.1.1
  176.             mline=arch||','||from||','||subj||','||mfor||','||mnum||','||anum||','||file
  177.             list ID MLST POS j STRING mline
  178.             iterate i
  179.          end
  180.       end
  181.    end
  182.  
  183.    window ID YTINF CLOSE
  184.  
  185. Return
  186.  
  187. /**************************************************************************/
  188. /*              Make sure YAM  and YAMTOOLS are running. Show YAM.        */
  189. /**************************************************************************/
  190. CheckYAM:
  191.  
  192.    if ~show('p','YAMTOOLS') then do
  193.       errmsg='You need YAMTOOLS running to use YTDelete'
  194.       say errmsg
  195.       exit
  196.    end
  197.  
  198.    if ~show('p','YAM') then do
  199.       errmsg='You need YAM running to use YTDelete'
  200.       Call ErrorMsg
  201.       exit
  202.    end
  203.  
  204.    Address YAM 'show'                       /* uniconify YAM's screen     */  
  205.  
  206.     Address YAM 'info SCREEN'                /* get YAM's screen           */
  207.     screen=result
  208.     if screen='' then screen='Workbench'
  209.  
  210. Return
  211.  
  212. /******************************************************************************/
  213. /*  Display ERROR message and EXIT.                                           */
  214. /******************************************************************************/
  215. ErrorMsg:
  216.  
  217.    window ID YTINF CLOSE
  218.  
  219.    request ID ERRM GADGETS '"OK"' errmsg
  220.  
  221.    exit
  222.  
  223. Return
  224.  
  225. /******************************************************************************/
  226. /*  Simple information/error message window.                                  */
  227. /******************************************************************************/
  228. InfoWindow:
  229.  
  230.    window ID YTINF TITLE '"YAM Deleter Info"' ATTRS MUIA_Window_PublicScreen screen,
  231.           MUIA_Window_SizeGadget FALSE MUIA_Window_DragBar FALSE,
  232.           MUIA_Window_DepthGadget FALSE
  233.  
  234.       group 
  235.          group 
  236.             text ID STEXT HELP help.STEXT  NODE node.STEXT LABEL infotext
  237.          endgroup
  238.          if showbusy then do
  239.             group
  240.                object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
  241.             endgroup
  242.          end
  243.          if infobuttons ~='' then do
  244.             group HORIZ
  245.                group 
  246.                   space HORIZ 
  247.                endgroup
  248.                group 
  249.                   radio ID SQUIT HELP help.SQUIT  NODE node.SQUIT LABELS infobuttons
  250.                endgroup
  251.                group 
  252.                   space HORIZ 
  253.                endgroup
  254.             endgroup
  255.          end
  256.          else do
  257.             group 
  258.                space HORIZ 100
  259.             endgroup
  260.          end
  261.       endgroup
  262.    endwindow
  263.  
  264. Return
  265.  
  266. /**************************************************************************/
  267. /*                           End of Active Code                           */
  268. /**************************************************************************/
  269.